const { defineConfig } = require('@vue/cli-service')
const createProxy = require('./dynamic_proxy');
const AutoImport = require('unplugin-auto-import/webpack')
const Components = require('unplugin-vue-components/webpack')
const { ElementPlusResolver } = require('unplugin-vue-components/resolvers')
module.exports = defineConfig({
  devServer: {
     port: '8050',
     open: true,
     proxy: {
       '/api': {
          target: 'http://192.168.31.222:8024',
          changeOrigin: true,
          pathRewrite: {'^/api': '/'},
          router: () => {
            return createProxy();
          },
       }
     }
  },
  transpileDependencies: true,
  configureWebpack: {
     performance: {
        hints: 'warning',
        // 入口起点的最大体积
        maxEntrypointSize: 50000000,
        // 生成文件的最大体积
        maxAssetSize: 30000000,
        // 只给出 js 文件的性能提示
        assetFilter: function (assetFilename) {
          return assetFilename.endsWith('.js')
        }
     },
     plugins: [
        AutoImport({
            resolvers: [ElementPlusResolver()],
     }),
     Components({
        resolvers: [ElementPlusResolver()],
     }),
   ],
  },
})